﻿using System;
using __ts.Core.Api;

/*
 *  author: able
 *  @2012/2/21 16:08:36
 * 
 */
namespace __ts.Core.Session
{
    /// <summary>
    /// 
    /// </summary>
    public abstract class AbstractIoSessionConfig : IoSessionConfig
    {
        //=====================
        // idle management
        //=====================    

        private long idleTimeRead = -1;

        private long idleTimeWrite = -1;

        /**
         * {@inheritDoc}
         */
        public long getIdleTimeInMillis(IdleStatus status)
        {
            switch (status)
            {
                case IdleStatus.READ_IDLE:
                    return idleTimeRead;
                case IdleStatus.WRITE_IDLE:
                    return idleTimeWrite;
                default:
                    throw new Exception("unexpected excetion, unknown idle status : " + status);
            }
        }

        /**
         * {@inheritDoc}
         */
        public void setIdleTimeInMillis(IdleStatus status, long ildeTimeInMilli)
        {
            switch (status)
            {
                case IdleStatus.READ_IDLE:
                    this.idleTimeRead = ildeTimeInMilli;
                    break;
                case IdleStatus.WRITE_IDLE:
                    this.idleTimeWrite = ildeTimeInMilli;
                    break;
                default:
                    throw new Exception("unexpected excetion, unknown idle status : " + status);
            }
        }
    }
}